#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

string s, t;
int n;
bool check(string s, string t) {
  int n = s.size();
  int x[128] = {0};
  int y[128] = {0};
  for (char c : s) x[c]++;
  for (char c : t) y[c]++;
  sort(x + 1, x + 128);
  sort(y + 1, y + 128);
  rep(i, 1, 127) if (x[i] != y[i]) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  while (cin >> s >> t) {
    cout << (check(s, t) ? "YES\n" : "NO\n");
  }
  return 0;
}